* WINDOWS PREAMBLE. 
#delimit ;


*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;	
/*	
	
PLEASE NOTE THE CODE HAS BEEN UPDATED SINCE PUBLICATION.

To find the edited code, look in the comments below.

In the published paper, the extensive margin elasticity is 
calculated using the indirect least squares estimate. For example, 
in table 1, column 1, the extensive margin elasticity is 0.65.

The elasticity equation is 
(ln(p_t0 + beta) - ln(p_t0))/(ln(i_tw1-i_tn1)- ln(i_tw1-i_tn1))

where 
p_t0 is the mean of the outcome in the pre period in the treatment group
i_tw1 is after tax and transfer income for those who are working in the post period
i_tn1 is after tax and transfer income for those who are not working in the post period
i_tw0 is after tax and transfer income for those who are working in the pre period
i_tn1 is after tax and transfer income for those who are not working in the pre period

In the published paper, beta is the indirect least squares estimate.
The ILS estimate is calculated by dividing the reduced form 
estimate by a first stage. In table 1, that is dividing the difference-
in-difference estimate of OBRA 93 on 100% poverty by the estimate 
from a regression where the outcome is realized EITC in $1,000s. 
We find this to be an error. 

For strategies where we use diff-in-diff, beta should be the coefficient
on treat*post. Where we use the parameterized, simulated EITC,
we need to multiply the estimate by the change in simulated EITC 
for the period. 

The log file contains output to replicate both versions of the 
elasticity under the headers Original Calculation and 
Corrected Calculation. 

See Addendum for more details on this change, and reporting of 
revised elasticities compared to published elasticities.  
 
		
*/
*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;	


global rawDir "LOCATION OF RAW CPS DATA";
global dataDir "WORKING DIRECTORY";
global currDir "PROGRAM DIRECTORY";
cd "$currDir" ;
capture log close ;
clear all ;
log using 4_SingleWomen_analysis.log, replace text;
global beginTime "DateTime: $S_DATE $S_TIME";
set more off ;
set linesize 255 ;
set matsize 10000 ;
set mem 2g ;
cd "$dataDir" ;


****************************************************************************************************;
* ANALYSIS ;
****************************************************************************************************;

local rsig = .0001 ;



****************************************************************************************************;
* FINAL RESTRICTIONS;
****************************************************************************************************;
use singleWomen ;
count ;


drop if statefip == 2 | statefip == 15;
count ;
keep if year>=1984&year<=2013;
count ;
keep if incdisab==0&incss==0&incssi==0 ;
count ;
keep if age>=24&age<=48;
count ;

replace age_44 = 1 if age == 48 ;
drop age_48 age_52 ;
drop childAgeBin_0_1 famtot;


*-------------------------------- ;
* ONLINE APPENDIX FIGURE 3 - SINGLE WOMEN ;
*-------------------------------- ;
preserve ;
gen eligible = fedEIC>0 ;
mat t = J(30,16,.z) ;
local r = 1 ;
foreach y of numlist 1984(1)2012 {;
	mat t[`r',1] = `y' ;
	local c = 2 ;
	foreach v of varlist hgc_11 hgc_12 hgc_13 hgc_16 hgc_17 {;	
		summ eligible if year==`y' & `v'==1 & qualChild>0 [aw=wtsupp], meanonly ;
		mat t[`r',`c']=round(r(mean),.0001) ;
		summ `v' if year==`y' & qualChild>0 [aw=wtsupp], meanonly ;
		mat t[`r',`c'+5]=round(r(mean),.0001) ;
		local c=`c'+1 ;
		local mean0 ;
		};
	local r=`r'+1 ;
	};
mat list t, nodotz ;
restore ;


****************************************************************************************************;
* VARIABLES AND LOCALS   ;
****************************************************************************************************;
drop unempr ;
gen emppop = emp/pop ;
gen unempr = (unemp/(unemp+emp)) ;
gen earnings = incwage+incbus+incfarm ;
gen children = min(qualChild,3) ;
gen byte races_1 = white ;
gen byte races_2 = hispanic ;
gen byte divorced_1 = divorced * (children >0) ;
gen byte divorced_2 = divorced * (children >1) ;
gen byte anywave_1 = anywave * (children>0) ;
gen byte anywave_2 = anywave * (children>1) ;
gen byte anywave_3 = anywave * (children>2) ;
gen ur_1 = unempr * (children>0) ;
gen ur_2 = unempr * (children>1) ;
gen ur_3 = unempr * (children>3) ;
gen stXyr = year*1000 * state ;
qui tab year, gen(yI) ;

local familyincome "famwage fambus famfarm famss famwelfr famgov 
	famaloth famretir famssi famdrt famint famunemp famwkcom famvet famsurv 
	famdisab famdivid famrent fameduc famchild famalim famasist famother" ;
egen cpsfamilyincome = rowtotal(`familyincome') ;
gen fatti = cpsfamilyincome+stampval+heatval+houssub+schlunch-fiitax-siitax-fica ;
	
egen inctaxes = rowtotal(fiitax siitax fica) ;
egen famearni = rowtotal(famwage fambus famfarm) ;
egen famchildplus = rowtotal(famaloth	famalim	famchild	famother	fameduc	famasist	famsurv) ;
gen cashwelfr = famwelfr ;
replace famwelfr = famwelfr + stampval+heatval+houssub+schlunch;
egen famcapitals = rowtotal(famint	famdrt	famdivid	famrent);
egen famgovern = rowtotal(famgov	famunemp	famvet	famwkcom ) ;
gen famresto = fatti + inctaxes - famearni - famwelfr - famchildplus - famcapitals ;
local income_comps "fatti inctaxes famearni famwelfr famchildplus famcapitals famresto" ;
*tabstat `income_comps' [aw=wtsupp] if `medEdu', by(year) s(mean) c(v) ;
foreach fpl of numlist 25(25)500 {;
	gen byte fpl`fpl' = (cpsfamilyincome>(`fpl'/100)*fpl) ;
	gen byte afpl`fpl' = (fatti>(`fpl'/100)*fpl) ;
	local povertyvars "`povertyvars' fpl`fpl' afpl`fpl'";
	};


gen realFedEic  = fedEIC/1000 ;
gen simFedEicUn = fedEICSIV_uni/1000 ;
gen simFedEic82 = fedEICSIV_82cps/1000 ;
gen simFedEic92 = fedEICSIV_92cps/1000 ;
gen treatChld1p = (year > 1993) * (children > 0) ;
gen treatChld1o = (year > 1993) * (children ==1) ;
gen treatChld2p = (year > 1993) * (children > 1) ;
gen post = year>1993 ;
gen treat1p = (children > 0) ;
gen treat2p = (children > 1) ;

global wgt "wtsupp" ;
local shrtDemoFedChld1 "yI* cI* age_* hgc_* races_* divorced" ;
local shrtDemoFedChld2 "yI* cI* age_* hgc_* races_* divorced" ;
local shrtDemoFedChld3 "yI* cI* age_* hgc_* races_* divorced" ;
local fuUnDemoFedChld1 "`shrtDemoFedChld1' fedRegTaxSIV_uni afdcSIV_uni anywave_1 ur_1" ;
local fuUnDemoFedChld2 "`shrtDemoFedChld2' fedRegTaxSIV_uni afdcSIV_uni anywave_2 ur_2" ;
local fu82DemoFedChld1 "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_1 ur_1" ;
local fu82DemoFedChld2 "`shrtDemoFedChld2' fedRegTaxSIV_82cps afdcSIV_82cps anywave_2 ur_2" ;
local fu82DemoFedChld3 "`shrtDemoFedChld3' fedRegTaxSIV_82cps afdcSIV_82cps anywave_3 ur_3" ;
local fu92DemoFedChld1 "`shrtDemoFedChld1' fedRegTaxSIV_92cps afdcSIV_92cps anywave_1 ur_1" ;
local fu92DemoFedChld2 "`shrtDemoFedChld2' fedRegTaxSIV_92cps afdcSIV_92cps anywave_2 ur_2" ;

local shrtYrFed "year>=1991&year<=1998" ;
local fullYrFed "year>=1984&year<=1998" ;
local longYrFed "year>=1984&year<=2013" ;
local allEdu "hgc>=0";
local lowEdu "hgc<13";
local medEdu "hgc<16";
local child "children>0";

local treat1plus "children>0";
local treat2plus "children>1";
local treat3plus "children>2";
local shrtprefed "year>1990&year<1994";
local shrtpostfed "year>1993";
local fullprefed "year==1984";
local fullpostfed "year>1993";
local longprefed "year==1984";
local longpostfed "year==2013";




*-------------------------------- ;
* APPENDIX TABLE 2 ;
*-------------------------------- ;
preserve ;
mat ss = J(31,4,.z) ;
gen hsormore = hgc>=12;
local sssamp1 "`fullYrFed'&`medEdu'&children==0";
local sssamp2 "`fullYrFed'&`medEdu'&children> 0";
local sssamp3 "`fullYrFed'&`medEdu'&children==1";
local sssamp4 "`fullYrFed'&`medEdu'&children> 1";
local c = 1 ;
foreach samp in sssamp1 sssamp2 sssamp3 sssamp4 {;
	local r = 1 ;
	foreach var of varlist age hsormore white qualChild divorced fedEIC employed famearni fatti afpl100 {;
		mean `var' if ``samp'' [aw=$wgt] , vce(cluster state);	 
		mat ss[`r',`c'] = _b[`var'] ;
		mat ss[`r'+1,`c'] = _se[`var'] ;
		local r = `r' + 2 ;
		};
	qui summ fatti [aw=$wgt] if ``samp'' ;	 
	mat ss[`r',`c']=r(N) ;
	local c = `c' + 1 ;
	};
mat list ss, nodotz ;
restore ;





****************************************************************************************************;

* THE CODE BELOW HAS BEEN UPDATED SINCE PUBLICATION ;


* REGRESSIONS (ONE PARAMETER) ;
****************************************************************************************************;
program define regHelper ;
	args matrix beginRow column tgroup pre post outcome endo treatment absorb controls sample;
	di "REG HELPER - `beginRow' `column' `outcome' `treatment' `sample' `absorb' `controls' ";
	di "REDUCED FORM ";
	areg `outcome' `treatment' `controls' if `sample' [aw=$wgt], absorb(`absorb') cluster(state) ;
	mat `matrix'[`beginRow',`column'] = _b[`treatment']; 
	local redform = _b[`treatment'] ;
	mat `matrix'[`beginRow'+1,`column'] = _se[`treatment']; 
	local ts = round(_b[`treatment']/_se[`treatment'], .01) ;
	mat `matrix'[`beginRow'+5,`column'] = e(N); 
	mat `matrix'[`beginRow'+7,`column'] = e(df_r); 
	di "FIRST STAGE " ;
	areg `endo' `treatment' `controls' if `sample' [aw=$wgt], absorb(`absorb') cluster(state) ;
	mat `matrix'[`beginRow'+2,`column'] = `matrix'[`beginRow',`column'] / _b[`treatment'] ; 
	summ `outcome' if `sample' [aw=$wgt], meanonly ;
	mat `matrix'[`beginRow'+3,`column'] = `matrix'[`beginRow'+2,`column'] / r(mean) ; 
	mat `matrix'[`beginRow'+6,`column'] = r(mean) ;
	
	
* In putting this replication package together we uncovered an error ;
* Original code, use to generate the results of the paper ;	

	summ `outcome' if `sample' & `tgroup' & year>1990&year<1994 [aw=$wgt] , meanonly ;	
	local p_t0_orig = r(mean) ;
	summ atti if `sample' & `tgroup' & year>1993 & earnings>0 [aw=$wgt] , meanonly ;	
	local i_tw1_orig = r(mean) ;
	summ atti if `sample' & `tgroup' & year>1993 & earnings==0 [aw=$wgt] , meanonly ;	
	local i_tn1_orig = r(mean) ;
	summ atti if `sample' & `tgroup' & year>1990&year<1994 & earnings>0 [aw=$wgt] , meanonly ;	
	local i_tw0_orig = r(mean) ;
	summ atti if `sample' & `tgroup' & year>1990&year<1994 & earnings==0 [aw=$wgt] , meanonly ;	
	local i_tn0_orig = r(mean) ;

	local beta_orig = `matrix'[`beginRow'+2,`column'] ;
	local e1_orig = (log(`p_t0_orig'+`beta_orig')-log(`p_t0_orig')) / (log(`i_tw1_orig'-`i_tn1_orig')-log(`i_tw0_orig'-`i_tn0_orig')) ;
* Original code end ;	
	
* Corrected code ;

	summ `outcome' if `sample' & `tgroup' & `pre' [aw=$wgt] , meanonly ;	
	local p_t0 = r(mean) ;
	summ atti if `sample' & `tgroup' & `post' & earnings>0 [aw=$wgt] , meanonly ;	
	local i_tw1 = r(mean) ;
	summ atti if `sample' & `tgroup' & `post' & earnings==0 [aw=$wgt] , meanonly ;	
	local i_tn1 = r(mean) ;
	summ atti if `sample' & `tgroup' & `pre' & earnings>0 [aw=$wgt] , meanonly ;	
	local i_tw0 = r(mean) ;
	summ atti if `sample' & `tgroup' & `pre' & earnings==0 [aw=$wgt] , meanonly ;	
	local i_tn0 = r(mean) ;
	
	gen temptreat = `tgroup'  ;
	summ `treatment' if `sample' & temptreat==1 & `post', meanonly;
	local simeitc_treat_post = r(mean) ;
	summ `treatment' if `sample' & temptreat==1 & `pre', meanonly ;
	local simeitc_treat_pre = r(mean) ;
	summ `treatment' if `sample' & temptreat==0 & `post', meanonly ;
	local simeitc_control_post = r(mean) ;
	summ `treatment' if `sample' & temptreat==0 & `pre', meanonly;
	local simeitc_control_pre = r(mean) ;	
	local simeitc_dnd = ((`simeitc_treat_post'-`simeitc_treat_pre')-(`simeitc_control_post'-`simeitc_control_pre')) ;
	local beta =  `simeitc_dnd' * `redform' ;
	drop temptreat ;
	
	local e1 = (log(`p_t0'+`beta')-log(`p_t0')) / (log(`i_tw1'-`i_tn1')-log(`i_tw0'-`i_tn0')) ;
	mat `matrix'[`beginRow'+4,`column'] = `e1' ; 
	
* Corrected code end ;	
	
	foreach s in e1 p_t0 p_t0_orig beta e1_orig beta_orig simeitc_treat_post simeitc_treat_pre simeitc_control_post simeitc_control_pre simeitc_dnd redform {;
		local `s' = round(``s'',.001) ;
		};
	foreach s in i_tw1 i_tn1 i_tw0 i_tn0 i_tw1_orig i_tn1_orig i_tw0_orig i_tn0_orig {;
		local `s' = round(``s'',1) ;
		};
		
	mat `matrix'[`beginRow'+8,`column'] = `p_t0' ;
	mat `matrix'[`beginRow'+9,`column'] = `i_tw0';
	mat `matrix'[`beginRow'+10,`column'] = `i_tn0';
	mat `matrix'[`beginRow'+11,`column'] = `i_tw1';
	mat `matrix'[`beginRow'+12,`column'] = `i_tn1';
	
	di "OUTPUT ELASTICITY CALCULATION ********* " ;
	di " " ;
	di " " ;
	di "ORIGINAL CALCULATION **************";
	di "  Mean of Outcome - `outcome' - in the pre-period `p_t0_orig'" ;
	di "      used in elasticity numerator" ;
	di " " ;
	di "  After Tax and Transfer Income for Elasticity Denominator" ;
	di "    ATTI, pre-period, working        `i_tw0_orig' ";
	di "    ATTI, pre-period, not working    `i_tn0_orig' ";
	di "    ATTI, post-period, working       `i_tw1_orig' ";
	di "    ATTI, post-period, not working   `i_tn1_orig' ";
	di " " ;
	di "  ILS estimate `beta_orig'" ;
	di "  Elasticity `e1_orig'" ;
	di " " ;
	di " " ;
	di "CORRECTED CALCULATION ***************** ";
	di "  Mean of Outcome - `outcome' - in the pre-period `p_t0'" ;
	di "      used in elasticity numerator" ;
	di " " ;
	di "  After Tax and Transfer Income for Elasticity Denominator" ;
	di "    ATTI, pre-period, working        `i_tw0' ";
	di "    ATTI, pre-period, not working    `i_tn0' ";
	di "    ATTI, post-period, working       `i_tw1' ";
	di "    ATTI, post-period, not working   `i_tn1' ";
	di " " ;	
	di "  Beta on treat*post or simulated EITC `redform'" ;
	di "  Amount simulated EITC changed due to policy `simeitc_dnd'" ;
	di "  Note that above amount is 1 for DnD specifications" ;
	di "  Values used to calculate simulated EITC change " ;
	di "    Treated group, post period  `simeitc_treat_post'";
	di "    Treated group, pre period  `simeitc_treat_pre'";
	di "    Control group, post period  `simeitc_control_post'";
	di "    Control group, pre period  `simeitc_control_pre'";
	di "    Note that above four calculations are 0s and 1s for the DnD specifications "; 
	di "  Final estimate to be used in numerator of elasticity calculation `beta' " ;
	di "  Elasticity `e1'" ;
	
	end ;


	
	
*-------------------------------- ;
* MAIN PAPER - TABLE 1 ;
* Difference-in-Difference Estimates of OBRA 93 on ATT Income above 100 percent of the Federal Poverty Threshold ;
*-------------------------------- ;
mat con = J(13,8,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "post"  "treat1p"            "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`fu82DemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "post"  "treat2p"            "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "5" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "6" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`fu82DemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* MAIN PAPER - TABLE 2 ;
* Parameterized DD Estimates of OBRA 93 on ATT Income above 100 Percent of the Federal Poverty Threshold ;
*-------------------------------- ;
mat con = J(13,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* MAIN PAPER - TABLE 3 ;
* Parameterized DD Estimates of TRA86, OBRA 90, and OBRA 93 on ATT Income above 100 Percent of the Federal Poverty Threshold ;
*-------------------------------- ;
mat con = J(13,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`fullprefed'" "`fullpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld1'" "`fullYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`fullprefed'" "`fullpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld1'" "`fullYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`fullprefed'" "`fullpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld2'" "`fullYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`fullprefed'" "`fullpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld2'" "`fullYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* MAIN PAPER - TABLE 4 ;
* Difference-in-Difference Estimates of OBRA 93 on Components of ATT Income :
*-------------------------------- ;
preserve ;
egen otherearn = rowtotal(famfarm fambus) ;
egen transfers = rowtotal( famss cashwelfr famgov famssi  famwkcom famvet famsurv famdisab fameduc heatval stampval houssub schlunch);
gen othertran = transfers - cashwelfr - stampval ;
mat ooo = J(14,18,.z) ;
local i = 1 ;
foreach dep in famwage otherearn cashwelfr stampval othertran inctaxes fatti {;
	regHelper "ooo" "  1" "`i'  " "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "`dep'" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
	local i = `i'+1 ;
	};
mat list ooo, nodotz ;
restore ;

*-------------------------------- ;
* MAIN PAPER Figure 6: Difference-in-Difference Estimates of OBRA 93 on ATT Income above Multiples of the Federal Poverty Threshold, Zero versus One or More Children ;
*-------------------------------- ;
mat con = J(20,12,.z) ;
mat h = J(13,1,.z) ;
local r = 1 ;
foreach fpl of numlist 25(25)500 {;
	regHelper "h" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl`fpl'" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
	mat con[`r',1]=h[1,1] ;
	mat con[`r',2]=h[2,1] *1.96;
	local r = `r'+1 ;
	};
mat drop h ;
mat list con, nodotz ;
mat drop con ;


*-------------------------------- ;
* MAIN PAPER Figure 7: Difference-in-difference Estimates of OBRA 93 on ATT Income above Multiples of the Federal Poverty Threshold, One Versus Two or More Children ;
*-------------------------------- ;
mat con = J(20,12,.z) ;
mat h = J(13,1,.z) ;
local r = 1 ;
foreach fpl of numlist 25(25)500 {;
	regHelper "h" "1" "1" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl`fpl'" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
	mat con[`r',1]=h[1,1] ;
	mat con[`r',2]=h[2,1] *1.96;
	local r = `r'+1 ;
	};
mat drop h ;
mat list con, nodotz ;
mat drop con ;


*-------------------------------- ;
* MAIN PAPER Figure 8: Parameterized DD Estimates of TRA 86, OBRA 90 and OBRA 93 on ATT Income above Multiples of the Federal Poverty Threshold ;
*-------------------------------- ;
mat con = J(20,12,.z) ;
mat h = J(13,1,.z) ;
local r = 1 ;
foreach fpl of numlist 25(25)500 {;
	regHelper "h" "1" "1" "`treat1plus'" "`fullprefed'" "`fullpostfed'" "afpl`fpl'" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld1'" "`fullYrFed' &`medEdu' " ;
	mat con[`r',1]=h[1,1] ;
	mat con[`r',2]=h[2,1] *1.96;
	regHelper "h" "1" "1" "`treat2plus'" "`fullprefed'" "`fullpostfed'" "afpl`fpl'" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld2'" "`fullYrFed' &`medEdu' &`child'" ;
	mat con[`r',3]=h[1,1] ;
	mat con[`r',4]=h[2,1] *1.96;
	local r = `r'+1 ;
	};
mat drop h ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* Appendix Table 3: Difference-in-Difference Estimates of OBRA93 on ATT Income Above 100% of the Poverty Threshold by Education Level ;
*-------------------------------- ;
mat con = J(27,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`allEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`fu82DemoFedChld1'" "`shrtYrFed' &`allEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`allEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`fu82DemoFedChld2'" "`shrtYrFed' &`allEdu' &`child'" ;
regHelper "con" "15" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`lowEdu' " ;
regHelper "con" "15" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`fu82DemoFedChld1'" "`shrtYrFed' &`lowEdu' " ;
regHelper "con" "15" "3" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`lowEdu' &`child'" ;
regHelper "con" "15" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`fu82DemoFedChld2'" "`shrtYrFed' &`lowEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* Appendix Table 4: Parameterized DD Estimates of OBRA93 on ATT Income Above 100% of the Poverty Threshold (1993 CPS) ;
*-------------------------------- ;
mat con = J(13,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic92" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic92" "stXyr" "`fu92DemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic92" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "simFedEic92" "stXyr" "`fu92DemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* Appendix Table 6: Parameterized DD Estimates of TRA86, OBRA90 and OBRA93 on ATT Income Above 100% of the Federal Poverty Threshold, 1984-2013 ;
*-------------------------------- ;
mat con = J(13,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`longprefed'" "`longpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld1'" "`longYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`longprefed'" "`longpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld1'" "`longYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`longprefed'" "`longpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld2'" "`longYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`longprefed'" "`longpostfed'" "afpl100" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld2'" "`longYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;

*-------------------------------- ;
* Appendix Table 7: Difference-in-Difference Estimates of OBRA93 on Any Work During the Year ;
*-------------------------------- ;
mat con = J(13,4,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld1p" "stXyr" "`fu82DemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "3" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld2p" "stXyr" "`fu82DemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;


*-------------------------------- ;
* Additional Calculations (Means) used in calculating Elasticities ;
* Output used to construct new table in appendix listing elasticities by education group and the components to calculate them ;
*-------------------------------- ;
mat con = J(13,12,.z) ;
regHelper "con" "1" "1" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "2" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "3" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`allEdu' " ;
regHelper "con" "1" "4" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`allEdu' &`child'" ;
regHelper "con" "1" "5" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`lowEdu' " ;
regHelper "con" "1" "6" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "employed" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`lowEdu' &`child'" ;
regHelper "con" "1" "7" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' " ;
regHelper "con" "1" "8" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`medEdu' &`child'" ;
regHelper "con" "1" "9" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`allEdu' " ;
regHelper "con" "1" "10" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`allEdu' &`child'" ;
regHelper "con" "1" "11" "`treat1plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld1p" "stXyr" "`shrtDemoFedChld1'" "`shrtYrFed' &`lowEdu' " ;
regHelper "con" "1" "12" "`treat2plus'" "`shrtprefed'" "`shrtpostfed'" "afpl100" "realFedEic" "treatChld2p" "stXyr" "`shrtDemoFedChld2'" "`shrtYrFed' &`lowEdu' &`child'" ;
mat list con, nodotz ;
mat drop con ;



*-------------------------------- ;
* Appendix Figure 8: Parameterized DD Estimates of TRA86, OBRA90 and OBRA93 on ATT Income Above Multiples of the Federal Poverty Threshold, 0 vs. 1+ Children, with and without Conservative control set ;
*-------------------------------- ;
mat con = J(20,4,.z) ;
mat h = J(13,1,.z) ;
local r = 1 ;
foreach fpl of numlist 25(25)500 {;
	regHelper "h" "1" "1" "`treat1plus'" "`fullprefed'" "`fullpostfed'" "afpl`fpl'" "realFedEic" "simFedEic82" "stXyr" "`shrtDemoFedChld1'" "`fullYrFed' &`medEdu' " ;
	mat con[`r',1]=h[1,1] ;
	mat con[`r',2]=h[2,1] *1.96;
	regHelper "h" "1" "1" "`treat1plus'" "`fullprefed'" "`fullpostfed'" "afpl`fpl'" "realFedEic" "simFedEic82" "stXyr" "`fu82DemoFedChld1'" "`fullYrFed' &`medEdu' " ;
	mat con[`r',3]=h[1,1] ;
	mat con[`r',4]=h[2,1] *1.96;
	local r = `r'+1 ;
	};
mat drop h ;
mat list con, nodotz ;
mat drop con ;

****************************************************************************************************;
* SUPPLEMENTAL TABLE 1 - Additional Difference in Difference Estimates for Any Work, assessing sensitivity to adding controls ;
****************************************************************************************************;

program define supptablehelper ;
	args outcome mat row col treatment ntreatment controls sample ;
	areg `outcome' `treatment' `controls' if `sample' [aw=$wgt], absorb(stXyr) cluster(state) ;
	if `ntreatment' == 1 {;
		mat `mat'[`row',`col'] = _b[`treatment'] ;
		mat `mat'[`row'+1,`col'] = _se[`treatment'] ;
		};
	if `ntreatment' == 2 {;
		local r = 0 ;
		foreach x in `treatment' {;
			mat `mat'[`row'+`r',`col'] = _b[`x'] ;
			mat `mat'[`row'+`r'+1,`col'] = _se[`x'] ;
			local r = `r' + 2 ;
			};
		};
	mat `mat'[7,`col'] = e(N) ;
	summ `outcome' if `sample' [aw=$wgt] ;
	mat `mat'[8,`col'] = r(mean) ;
	end ;
	
mat h = J(8,12,.z) ;

supptablehelper "employed" "h" "1" "1" "treatChld1p" "1" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "1" "2" "treatChld1p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "1" "3" "treatChld1p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_1" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "1" "4" "treatChld1p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_1 ur_1" "`shrtYrFed' &`medEdu'";

supptablehelper "employed" "h" "3" "5" "treatChld1o treatChld2p" "2" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "3" "6" "treatChld1o treatChld2p" "2" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "3" "7" "treatChld1o treatChld2p" "2" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_1 anywave_2" "`shrtYrFed' &`medEdu'";
supptablehelper "employed" "h" "3" "8" "treatChld1o treatChld2p" "2" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_1 anywave_2 ur_1 ur_2" "`shrtYrFed' &`medEdu'";

supptablehelper "employed" "h" "5" "9" "treatChld2p" "1" "`shrtDemoFedChld1'" "`shrtYrFed' &`medEdu' & `child'";
supptablehelper "employed" "h" "5" "10" "treatChld2p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps" "`shrtYrFed' &`medEdu' & `child'";
supptablehelper "employed" "h" "5" "11" "treatChld2p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_2" "`shrtYrFed' &`medEdu' & `child'";
supptablehelper "employed" "h" "5" "12" "treatChld2p" "1" "`shrtDemoFedChld1' fedRegTaxSIV_82cps afdcSIV_82cps anywave_2 ur_2" "`shrtYrFed' &`medEdu' & `child'";

mat list h , nodotz ;
mat drop h ;




****************************************************************************************************;
* EVENT TIME ;
****************************************************************************************************;
program define regHelper3 ;
	args matrix column outcome year beginyear endyear omit rsig xlist absorb sample ngroups control treat1 treat2;
	di "EVENT STUDY - `matrix' `column' `outcome' `year' `beginyear' `endyear' `omit' `ngroups' `rsig' `control' `treat1' `treat2' `xlist' `absorb' `sample' ";
	foreach y of numlist `beginyear'(1)`endyear' {;
		if `y' != `omit' {;
			gen byte eDnd1_`y' = (`treat1') & (`year'==`y'); 
			local etvars "`etvars' eDnd1_`y'" ;
			if `ngroups' == 2 {;
				gen byte eDnd2_`y' = (`treat2') & (`year'==`y'); 
				local etvars "`etvars' eDnd2_`y'" ;
				};
			};
		};
	if `ngroups'==1 {;
		local subby "if `year'>=`beginyear'&`year'<=`endyear'&`sample'&(`control'|`treat1')"; 
		};
	if `ngroups'==2 {;
		local subby "if `year'>=`beginyear'&`year'<=`endyear'&`sample'&(`control'|`treat1'|`treat2')"; 
		};
	qui gen flatness = . ; 
	qui gen t = . ;
	areg `outcome' `etvars' `xlist' `subby' [aw=$wgt], absorb(`absorb') cluster(state) ;
	foreach y of numlist `beginyear'(1)`endyear' {;
		if `y' != `omit' {;
			mat `matrix'[`y'-1984+1,`column'] = round(_b[eDnd1_`y'],`rsig') ;
			mat `matrix'[`y'-1984+1,`column'+1] = round(_se[eDnd1_`y']*1.96,`rsig') ;
			if `ngroups' == 2 {;
				mat `matrix'[`y'-1984+1,`column'+2] = round(_b[eDnd2_`y'],`rsig') ;
				mat `matrix'[`y'-1984+1,`column'+3] = round(_se[eDnd2_`y']*1.96,`rsig') ;
				};
			};
		if `y' == `omit' {;
			mat `matrix'[`y'-1984+1,`column'] = 0;
			if `ngroups' == 2 {;
				mat `matrix'[`y'-1984+1,`column'+1] = 0 ;
				};
			};
		if `y' <= `omit' {;
			qui replace t = `y'-`beginyear'+1 if _n==`y'-`beginyear'+1 ;
			if `y' != `omit' {;
				qui replace flatness = round(_b[eDnd1_`y'],`rsig') if _n==`y'-`beginyear'+1 ;
				};
			if `y' == `omit' {;
				qui replace flatness = 0 if _n==`y'-`beginyear'+1 ;
				};
			};
		};
	drop eDnd* ;
	gen byte tempet1 = (`year' >`omit') * (`treat1') ;
	if `ngroups'==2 {;
		gen byte tempet2 = (`year' >`omit') * (`treat2') ;
		};
	areg `outcome' tempet* `xlist' `subby' [aw=$wgt], absorb(`absorb') cluster(state) ;
	mat `matrix'[31,`column'] = round(_b[tempet1],`rsig') ;
	mat `matrix'[31,`column'+1] = round(_se[tempet1]*1.96,`rsig') ;
	if `ngroups'==2 {;
		mat `matrix'[31,`column'+2] = round(_b[tempet2],`rsig') ;
		mat `matrix'[31,`column'+3] = round(_se[tempet2]*1.96,`rsig') ;
		};
	drop tempet* ;
	qui reg flatness t if flatness!=. ;
	drop flatness t;
	end ;



	
program define trends ;
	args matrix column outcome rsig sample absorb xlist1 xlist2 ;
	di "UNCONDITIONAL MEANS BY GROUP FOR EMPLOYMENT AND POVERTY - `outcome' ";
	local r = 1 ;
	foreach y of numlist 1984(1)2013 {;
		qui summ `outcome' if year==`y' &`sample'& children==0, meanonly ;
		mat `matrix'[`r',`column']=round(r(mean),`rsig') ;
		qui summ `outcome' if year==`y' &`sample'& children==1, meanonly ;
		mat `matrix'[`r',`column'+1]=round(r(mean),`rsig') ;
		qui summ `outcome' if year==`y' &`sample'& children>1, meanonly ;
		mat `matrix'[`r',`column'+2]=round(r(mean),`rsig') ;
		local r=`r'+1 ;
		};
	end ;	
	

	
*-------------------------------- ;
* Figure 3a - Poverty by Family Size ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
trends "r" "2" "afpl100" ".0001" "`medEdu'" "stXyr" "`shrtDemoFedChld1'" "`shrtDemoFedChld2'";
mat list r, nodotz ;
mat drop r ;

*-------------------------------- ;
* Figure 3b - Employment by Family Size ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
trends "r" "2" "employed" ".0001" "`medEdu'" "stXyr" "`shrtDemoFedChld1'" "`shrtDemoFedChld2'";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Figure 4a - Event Time Model Estimates of OBRA 93 on ATT Income above 100 Percent of the Poverty Threshold ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "afpl100" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Figure 4b - Event Time Model Estimates of OBRA 93 on ATT Income above 100 Percent of the Poverty Threshold ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "afpl100" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;

*-------------------------------- ;
* Figure 5 - Event Model Estimates of OBRA 93 on ATT Income above 100 Percent of the Poverty Threshold, One versus Two or More Children ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "afpl100" "year" "1984" "1998" "1993" ".0001" "`shrtDemoFedChld2'" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Appendix Figure 5: Event Model Estimates of TRA86, OBRA90 and OBRA93 on ATT Income Above 100% of the Poverty Threshold ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "afpl100" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Appendix Figure 6: Event Model Estimates of TRA86, OBRA90 and OBRA93 on ATT Income Above 100% of the Poverty Threshold by family size ; 
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "afpl100" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;



*-------------------------------- ;
* Appendix Figure 7: Event Model Estimates of TRA86, OBRA90 and OBRA93 on ATT Income Above 100% of the Poverty Threshold, 1 vs 2+ Children ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "afpl100" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld2'" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Appendix Figure 9a: Event Time Model Estimates of OBRA 93 on Any Work During the Year ;
*-------------------------------- ;

mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "employed" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Appendix Figure 9b: Event Time Model Estimates of OBRA 93 on Any Work During the Year ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "employed" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;



****************************************************************************************************;
* ONLINE APPENDIX - SUPPLEMENTARY TABLES AND FIGURES ;
****************************************************************************************************;

*-------------------------------- ;
* Supplemental Figure 1: Event Model Estimates of OBRA 93 on Any Work, 1 vs 2+ Children, 1984-1998, No State x year controls for Unemployment or Waivers ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "1998" "1993" ".0001" "`shrtDemoFedChld2'" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;

*-------------------------------- ;
* Supplemental Figure 2: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 1984-2013, ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 3: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 2+ Children vs no children and 1 child versus no children, ; 
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 4: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 1 vs 2+ Children NO controls for Unemp and Waivers;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld2'" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 5a : Event Time Model Estimates of OBRA 93 on Any Work During theYear, 0 vs. 1+ Children ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "employed" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 5b : Event Time Model Estimates of OBRA 93 on Any Work During theYear,  2+ children vs No Children and 1 Child vs No Children ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2"  "employed" "year" "1991" "1998" "1993" ".0001" "`shrtDemoFedChld1'" "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;



*-------------------------------- ;
* Supplemental Figure 6: Event Model Estimates of OBRA 93 on Any Work, 1 vs 2+ Children, 1984-1998, Controls for Unemployment and Waivers ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "1998" "1993" ".0001" "`shrtDemoFedChld2' anywave_2 ur_2" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 7: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 1984-2013, Controls for Unemployment and Waivers ;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1' anywave_1 ur_1" "stXyr" "`medEdu'" "1" "children==0" "children>=1" "";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 8: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 2+ Children vs no children and 1 child versus no children, Controls for Unemployment and Waivers ; 
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld1' anywave_1 ur_1  " "stXyr" "`medEdu'" "2" "children==0" "children==1" "children>=2";
mat list r, nodotz ;
mat drop r ;


*-------------------------------- ;
* Supplemental Figure 9: Event Model Estimates of TRA86, OBRA90 and OBRA93 on Any Work, 1 vs 2+ Children, Controls for Unemployment and Waivers;
*-------------------------------- ;
mat r = J(31,21,.z) ;
foreach y of numlist 1984(1)2013 {;
	mat r[`y'-1984+1,1]=`y';
	};
regHelper3 "r" "2" "employed" "year" "1984" "2013" "1993" ".0001" "`shrtDemoFedChld2' anywave_2 ur_2" "stXyr" "`medEdu'" "1" "children==1" "children>=2" "";
mat list r, nodotz ;
mat drop r ;



****************************************************************************************************;
* POVERTY SIMULATION ;
* Figure 9 - The Effect of the EITC on the Aggregate Number of Individuals above Multiples of the Federal Poverty Threshold, 2012 ;
****************************************************************************************************;
egen pwt = rowtotal(wtsupp chldwt) ; /* ALL PEOPLE WEIGHT */
mat bgp = J(15,3,.z) ;
local row = 1 ;
foreach m of numlist 50(50)300 {;
	gen byte spmtemp = spmtotres<(spmthres*`m'/100) ;
	gen byte spmeitctemp = spmtotres-spmeitc<(spmthres*`m'/100) ; 
	gen byte attipovtemp = fatti<(fpl*`m'/100);
	gen byte attipoveitctemp = fatti-fedEIC<(fpl*`m'/100);
	gen simtemp = simFedEic82 ;
	areg attipovtemp simtemp `fu82DemoFedChld1' if year>=1984&year<=2013&`medEdu' [aw=$wgt], absorb(stXyr) cluster(state) ;
	predict hattemp ;
	drop simtemp ;
	gen simtemp = 0 ;
	predict hat0temp ;
	drop simtemp ;
	foreach var of varlist spmtemp spmeitctemp attipovtemp attipoveitctemp hattemp hat0temp {;
		foreach wt in pwt chldwt {;
			summ `var' [aw=`wt'] if year==2012&`medEdu'&`child';
			local `var'_`wt' = r(sum) ;
			};
		};		
	mat bgp[`row'+8,1]= `spmeitctemp_pwt'-`spmtemp_pwt';
	mat bgp[`row'+8,2]= `attipoveitctemp_pwt'-`attipovtemp_pwt';
	mat bgp[`row'+8,3]= `hat0temp_pwt'-`hattemp_pwt' ;
	mat bgp[`row',1]= `spmeitctemp_chldwt'-`spmtemp_chldwt';
	mat bgp[`row',2]= `attipoveitctemp_chldwt'-`attipovtemp_chldwt';
	mat bgp[`row',3]= `hat0temp_chldwt'-`hattemp_chldwt' ;
	foreach var of varlist spmtemp spmeitctemp attipovtemp attipoveitctemp hattemp hat0temp {;
		drop `var' ;
		foreach wt in pwt chldwt {;
			local `var'_`wt' ;
			};
		};
	local row = `row'+1 ;
	};
mat list bgp, nodotz ;

*/
*;
log close ;























